package ga;

import pso.Utility;
import function.Function;

public class Individual {

	private double[] gens;
	private double fitness;
	private pso.Function f;
	
	public Individual(pso.Function f) {
		this.f = f;
		initialize();
	}
	
	public Individual(pso.Function f , double [] gens) {
		this.f = f;
		initialize();
		this.gens = gens;
	}
	
	private void initialize() {
		
		//inicializa a dimensao do invididuo
		this.gens = new double[f.getNumDimensions()];
		//inicializar cada espaço do vetor com um número entre f.getMinBoudaries() e f.getMaxBoudaries()
		//Configura o tamanho de genes
		for (int i = 0; i < gens.length; i++) {
			 gens[i] = Utility.between(f.getMinBoudaries(), f.getMaxBoudaries());
		}
		
	}

	public double[] getGens() {
		return gens;
	}
	public void setGens(double[] gens) {
		this.gens = gens;
	}
	public double getFitness() {
		return fitness;
	}
	public void setFitness(double fitness) {
		this.fitness = fitness;
	}
	public void calculateFitness(){
		setFitness(this.f.calculate(this.gens));
	}
	
	
	
	public pso.Function getF() {
		return f;
	}

	public void setF(pso.Function f) {
		this.f = f;
	}

	
	
	
}
